<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <?php echo $html->charset(); ?>
  <title><?php __($currentCity); __(' Classifield Ads'); e(' | '); __($title_for_layout); ?></title>
<?php
  echo $html->meta('icon');
  echo $html->css('reset');
  echo $html->css('grid');
  echo $html->css('type');
  echo $html->css('style');
  if (is_array($javascripts)) {
     foreach ($javascripts as $js) {
        echo $javascript->link($js);
     }
  }
  echo $scripts_for_layout;
?>
<script type="text/javascript" src="http://localhost/lib/firebug/firebug.js"></script>
<script type="text/javascript" charset="utf-8">
    var mesg = {
        onSaving: '<?php __('Saving..'); ?>',
        onFail: '<?php __('Fail making page request!'); ?>',
        onSuccess: '<?php __('Form data saved!'); ?>',
        invalid: '<?php __('Please enter the requested details in the fields pointed out below and try again!'); ?>'
    };

    if (typeof Prototype != 'undefined') {
        document.observe("dom:loaded", function() {
            if ($('logo')) {
                $('logo').observe('mouseover', function(){
                    $('changeLogo').removeClassName('hide');
                });
                $('logo').observe('mouseout', function(){
                    $('changeLogo').addClassName('hide');
                });
            }
        });
    }

    var imageUploader = {
        init: function () {
            this.effect = 1;
            this.url = '<?php e($this->base.'/uploadImage.aux.php'); ?>';
        },

        open: function (name) {
            if ($('div_'+name)) {
                return;
            }

            this.init();
            this.name = name;

            var def = $(name).style.backgroundImage;
            var len = def.length - 5;
                def = def.substr(4, len);
            var tpl = '<div id="div_'+name+'" class="abs" style="display:none; background-color:#FFF8CC; border-top:1px solid #EBAE7F; padding:5px;">'+
                        '<div class="arrowUp"></div>'+
                        '<span id="txt_'+name+'">Select an image file on your computer</span>'+
                        '<form id="form_'+name+'" enctype="multipart/form-data" method="post" action="'+this.url+'">'+
                          '<input type="file" id="image_'+name+'" name="image_'+name+'" value="" onchange="imageUploader.upload(\''+name+'\')" />'+
                          '<input type="hidden" name="itag" value="'+name+'" />'+
                          '<input type="hidden" name="defaultImage" value="'+def+'" />'+
                          '<input type="hidden" id="iWidth" name="iWidth" value="" />'+
                          '<input type="hidden" id="iHeight" name="iHeight" value="" />'+
                          '<div style="color:#3B5998; text-align:right; cursor:pointer;" onclick="imageUploader.kill(\'div_'+name+'\')">close</div>'+
                        '</form>'+
                      '</div>';
            var width  = $(name).getWidth();
            var height = $(name).getHeight();

            $(name).insert(tpl);

            var tWidth = $('div_'+name).getWidth();
            var offset = (width - tWidth) / 2;

            $('div_'+name).setStyle({ top:(height-5)+'px', left:offset+'px' });
            $('iWidth').value  = width;
            $('iHeight').value = height;

            if (this.effect) {
                new Effect.Appear('div_'+name, { duration:1 });
                new Effect.BlindDown('div_'+name, { duration:0.5 });
            } else {
                $('div_'+name).show();
            }
        },

        upload: function (elem) {
            if (!$F('image_'+elem)) {
                window.effect = new Effect.Pulsate('uploadImage', {
                    afterUpdate: function(o) {
                        if (o.currentFrame > 120) { window.effect.cancel(); }
                    },
                    afterFinish: function() {
                        $('image_'+elem).focus();
                    }
                });
                return false;
            }

            AIM.submit($('form_'+elem), { 'onComplete':this.complete });
            $('form_'+elem).submit();

            $('txt_'+elem).update('uploading..').setStyle({ color:'gray' });
            $('image_'+elem).remove();
            $('form_'+elem).insert({ top:'<div id="loading_'+elem+'" class="uploadBar"></div>' });
            //setTimeout("imageUploader.complete('"+elem+"')", 3000);

            if (this.effect) {
                new Effect.Pulsate('txt_'+elem);
            }
        },

        complete: function (response) {
            var json = {};//response.evalJSON();
            var elem = this.name;

            $('loading_'+elem).remove();

            if (json.status != 1) {
                var err = (json.message) ? json.message : '<?php __('Fail upload image, please try again..'); ?>';
                $('txt_'+elem).update(err).setStyle({ color:'red' });
                $('form_'+elem).insert({ top:'<input type="file" id="image_'+elem+'" name="image_'+elem+'" value="" onchange="imageUploader.upload(\''+elem+'\')" />' });

                if (this.effect) {
                    window.effect = new Effect.Pulsate('txt_'+elem, {
                        delay: 0.5,
                        afterUpdate: function(o) {
                            if (o.currentFrame > 120) { window.effect.cancel(); }
                        }
                    });
                }
                return false;
            } else if (json.status == 1) {
                $('txt_'+elem).update('image uploaded successfully!').setStyle({ color:'green' });
                setTimeout("imageUploader.kill('div_"+elem+"')", 2000);

                if (json.newimage) {
                    $(elem).setStyle({ backgroundImage:'url('+json.newimage+')' });
                }
                if (this.effect) {
                    new Effect.Highlight('txt_'+elem);
                }
            }
        },

        kill: function (elem) {
            if (this.effect) {
                new Effect.DropOut(elem, { afterFinish:function(){
                    $(elem).remove();
                } });
            } else {
                $(elem).remove();
            }
        }
    };
</script>
</head>
<body>

<div class="rel" style="z-index:2;">
  <div class="abs" style="width:100%;">
    <div style="width:90em; margin:0 auto;">
      <div id="loginpanel" class="center" style="display:none; background-color:#FEF8CE; padding-bottom:13px;">
<?php echo $form->create('User', array('url'=>'/users/login')); ?>
        <div class="dr hand" style="margin-right:5px;" onclick="loginPanel()"><?php __('Close Panel'); ?></div>
        <div style="padding:10px 0 5px 0;">
          <?php __('Email:'); ?> <?php echo $form->input('User.email', array('label'=>false, 'div'=>false)); ?>
          <?php __('Password:'); ?> <input type="password" id="UserPassword" name="data[User][password]" value="" />
          <input type="submit" value="<?php __('Sign In'); ?>" />
        </div>
        <span style="padding-right:30px;"><input type="checkbox" id="remeberme" /><?php __('Remember me'); ?></span>
        <?php __('Not a member?'); ?>
        <?php echo $html->link(__('Register', true), '/users/register'); ?> |
        <?php echo $html->link(__('Lost your password?', true), '/users/forgot'); ?>
<?php echo $form->end(); ?>
      </div>

      <div id="menubar_aux" class="dr center bl" style="background-color:#FEF8CE;">
<?php if (empty($myname)) { ?>
        <?php echo $html->link(__('Register', true), '/users/register'); ?> |
        <span class="link" onclick="loginPanel()"><?php __('Sign In'); ?></span>
<?php } else { ?>
        <?php echo $html->link(__('Hi ',true).$myname, '/users/home'); ?> |
        <?php echo $html->link(__('Sign Out',true), '/users/logout'); ?>
<?php } ?>
      </div>
    </div>
  </div>
</div>

  <div id="container" class="main" style="min-height:100%;">

    <div id="header" class="hp">
      <div id="logo" title="<?php __($sitename); ?>" class="dl15 rel bl" style="height:120px; background-image:url(<?php e($this->base.'/img/logo.gif'); ?>);">
        <div id="changeLogo" onclick="imageUploader.open('logo');" class="hide"><?php __('Change Logo'); ?></div>
      </div>
      <div id="menubar_core" class="dl40 bl" style="height:40px; padding-top:20px;">
        <?php echo $html->link(__('Categories',true), '/adCategories'); ?>
        <?php echo $html->link(__('Post Ad',true), '/adCategories/selectCategory'); ?>
        <?php echo $html->link(__('My Account',true), '/users/home'); ?>
        <?php echo $html->link(__('Help',true), '/pages/help'); ?>
      </div>
      <div id="menubar_location" class="dl40 bl" style="height:60px;">
        <h1 style="display:inline; color:#FF9900;"><?php __($currentCity); ?></h1>
        <a href="<?php e($this->base.'/locations/all'); ?>"><?php __('Change City'); ?></a>
      </div>
      <div id="menubar_search" class="dl35 center bl">
        <input type="text" id="main_search" />
        <?php echo $this->element('categories', array('cache'=>true)); ?>
        <input type="button" value="<?php __('Search'); ?>" />
      </div>
    </div>

    <div id="content" class="hp bl">
      <div id="innerContent" style="margin:15px 10px 10px 10px;">
<?php if ($session->check('Message.flash') || $session->check('Message.auth')) { ?>
        <div id="messageBox" style="margin-bottom:5px;"><?php echo $session->flash().$session->flash('auth'); ?></div>
        <div class="clear"></div>
<?php } else if ($session->check('Message.email')) { ?>
        <div id="messageBox" style="margin-bottom:5px;"><?php echo $session->flash('email'); ?></div>
        <div class="clear"></div>
<?php } ?>
        <div id="page_content" class="bl">
          <table>
            <tr>
              <td></td>
              <td style="width:100%;">
                <div id="banner" class="bl"></div>
                <?php echo $content_for_layout; ?>
              </td>
              <td>
                <div id="elements" class="bl dr" style="width:230px; display:none;">
                  side modules
                </div>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>

    <div id="footer" class="hp">
<?php if (isset($areas) && count($areas) > 0) { ?>
      <div id="footer_cities" style="margin: 0 0 5px 3px;">
        <?php __('Other Areas:'); ?>
<?php     foreach ($areas as $id=>$area) { ?>
        <a href="<?php e($this->base); ?>/locations/city/<?php e($id); ?>"><?php __($area); ?></a>
<?php     } ?>
      </div>
<?php } ?>
<?php if (!empty($countries) && count($countries) > 0) { ?>
      <div id="footer_countries" style="margin: 0 0 10px 3px;">
        <?php __('Other countries/regions:'); ?>
<?php     foreach ($countries as $id=>$country) { ?>
        <a href="<?php e($this->base); ?>/locations/country/<?php e(low($country)); ?>/<?php e($id); ?>"><?php __($country); ?></a>
<?php     } ?>
      </div>
<?php } ?>
      <div id="footer_links" style="margin-left:8px; padding-top:5px; border-top:1px solid #BEC3C7;">
        <?php echo $html->link(__('Help', true), 'javascript:;'); ?> |
        <?php echo $html->link(__('About', true), '/about.html'); ?> |
        <?php echo $html->link(__('Privacy Policy', true), '/policy.html'); ?> |
        <?php echo $html->link(__('Terms of Use', true), '/terms.html'); ?> |
        <?php echo $html->link(__('Contact Us', true), '/contact.html'); ?>
      </div>
      <div id="copyright">
        <?php __('copyright'); ?> <?php echo $html->link('&copy;','/admin/pages/cpanel',array('style'=>'color:#000;background-color:transparent;'),false,false); ?> <?php e(date('Y')); ?> <?php __($sitename); ?>
      </div>
      <div class="clear"></div>
    </div>
  </div>
  <div style="color:#ccc;">
    <?php echo $cakeDebug; ?>
  </div>

</body>
</html>
